package main;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/** Validate
 * Class Validate validates the url about to be added to the queue , and whether it is
 * a valid URL in form and acceptability. Validate uses a hashSet to keep visited links
 * so that we do not visit any link more than once. or some not at all.
 * * @author T. Lewis & Ken Norton BitWiseGuys.
 *  **/
public class Validate {

	private static HashSet<String> visited;

	public Validate(){
		visited = new HashSet<String>();
	}

	public boolean contains(String the_URL){

		return visited.add(the_URL);
	}

	public static void visit(String the_URL){
		visited.add(the_URL);
	}

	/** isValid checks the Link against invalid specifications**/
	static boolean isValid(String the_link){
		boolean flag = true;

		if (the_link.endsWith(".html")||the_link.endsWith("/")||the_link.endsWith(".txt")||the_link.endsWith(".htm")){
			//asd

			flag = true;
		} else {flag = false;}
		/**NO - NO! do not visit**/
		if(the_link.startsWith("http://questioneverything.typepad.com/")){
			flag = false;

		}else if(the_link.startsWith("https://")){
			flag = false;
		}else if(the_link.startsWith("http://www.youtube.com")){
			flag = false;

		}else if(the_link.startsWith("http://www.facebook.com")){
			flag = false;

		} else if(!the_link.startsWith("http:")){
			flag = false;

		} else if (the_link.endsWith(".m4v")){
			flag = false;
		} else if (the_link.endsWith(".mp4")){
			flag = false;
		} else if (the_link.endsWith(".pdf")){
			flag = false;
		} else if (the_link.endsWith("#")){
			flag = false;	
		} else if (visited.contains(the_link)){
			flag = false;
		}

		return flag;
	}

	/**Returns the List of Visited Links**/
	public static List<String> visitedLinks(){
		List<String> tempList = new ArrayList<String>();
		return tempList;
	}
}